<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!-- v-for
       1、用于展示列表数据
       2、语法：v-for="(item, index) of items" :key="index"
       3、可遍历：数组、对象
  -->
  <!-- 准备好一个容器-->
  <div id="app">
    <!-- 遍历数组 -->
    <table border="1" cellspacing="0">
      <tr v-for="student of students" :key="student.id">
        <td>{{student.id}}</td>
        <td>{{student.name}}</td>
        <td>{{student.age}}</td>
      </tr>
    </table>
    <br/>
    <table border="1" cellspacing="0">
      <tr v-for="(student, index) of students" :key="index">
        <td>{{index}}</td>
        <td>{{student.id}}</td>
        <td>{{student.name}}</td>
        <td>{{student.age}}</td>
      </tr>
    </table>
    <!-- 遍历对象 -->
    <ul>
      <li v-for="(value, key, index) of banji">
        {{index+1}}--{{key}}--{{value}}
      </li>
    </ul>
    <ul>
      <li v-for="(value, key) of banji">
        {{key}}--{{value}}
      </li>
    </ul>
    
    <!-- 遍历指定次数 -->
    <ul>
      <li v-for="i of 5">
        {{i}}
      </li>
    </ul>
    <ul>
      <li v-for="(i, index) of 5">
        {{i}}--{{index}}
      </li>
    </ul>

  </div>
  <script src="vue.js"></script>
  <script>
    Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示。
    //创建vue实例
    new Vue({
      el: '#app',
      data: {
        students: [
          {id: 1, name: '张三1', age: 23},
          {id: 2, name: '张三2', age: 23},
          {id: 3, name: '张三3', age: 23},
        ],
        banji: {
          id: 1,
          name: 'java230301',
          count: 49
        }
      }
    })
  </script>
</body>

</html>